package com.dks.controller.student;

import com.dks.result.Result;
import com.dks.result.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.dks.dto.BaseIdRequestDto;
import com.dks.dto.student.LeaveDto;
import com.dks.exception.BaseException;
import com.dks.repository.IStudentClassRepository;
import com.dks.result.ResultModel;

/**
 * 学生班级相关
 */
@RestController
@RequestMapping("student-class")
public class StudentClassController {

    @Autowired
    private IStudentClassRepository studentClassRepository;

    /**
     * 请假提交
     *
     * @param leaveDto id 课程id
     * @author evan
     */
    @RequestMapping("leave")
    public ResultModel<Boolean> leave(@RequestBody @Validated LeaveDto leaveDto) {
        return studentClassRepository.leave(leaveDto);
    }

    /**
     * 停课提交--用户主动停课
     *
     * @param baseIdRequestDto id 课程系列id
     * @author evan
     */
    @RequestMapping("suspend")
    public ResultModel<Boolean> suspend(@RequestBody @Validated BaseIdRequestDto baseIdRequestDto) throws BaseException {
        return studentClassRepository.suspend(baseIdRequestDto);
    }

    /**
     * @Author: kennychan
     * @Description: 【教务】获取系统的全部课表
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("all")
    public ResultModel<Object> tcGetAllTeacherCourseList(Long studentId, String beginTime, String endTime, Long courseCategoryId, Integer pageNum, Integer pageSize, String studentBirthDay) {
        if (null == pageNum) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageNum");
        }
        if (null == pageSize) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "pageSize");
        }
        if (null == studentId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "studentId");
        }
        return studentClassRepository.getStudentClassList(studentId, beginTime, endTime, courseCategoryId, studentBirthDay, pageNum, pageSize);
    }

    /**
     * @Author: kennychan
     * @Description: 获取系统课表详情
     * @Date: 9:52 2020/4/23
     * @Modificd By:
     * @Param: teacherId 老师id
     * @Param: pageNum 页码
     * @Param: pageSize 条数
     * @return:
     * @throw: 请描述异常信息
     */
    @GetMapping("detail/{id}")
    public ResultModel<Object> getStudentClassDetail(@PathVariable(value = "id") Long studentClassId) {
        if (null == studentClassId) {
            return Result.makeResult(ResultInfo.ERR_PARAM_NULL, "studentClassId");
        }
        return studentClassRepository.getStudentClassDetail(studentClassId);
    }


}
